<%@ page import="databeans.*"%>
<html>
<head>

<title>Employee Transition Day</title>
</head>
<body>

<h1>Transition day screen</h1>

<%
    java.util.List<String> errors = (java.util.List) request.getAttribute("errors");
	if (errors != null && errors.size() > 0) {
		for (String error : errors) {
%>
			<%= error %> <br/>
<% 
		}
	}
%>

<%
    java.util.List<String> messages = (java.util.List) request.getAttribute("messages");
	if (messages != null && messages.size() > 0) {
		for (String message : messages) {
%>
			<%= message %> <br/>
<% 
		}
	}
%>
	
	
	<form name="transition" action="employeeExecuteTransition.do" method="post">
	
	<p>Date: <input type="text" name="transDate" size="10" value="${transDate}" /> (format: yyyy-MM-dd)</p>
	
	<% if (request.getAttribute("fundsDateOfLastTransaction")!=null) { %>
	
	<p>Date of last transaction: <%= request.getAttribute("fundsDateOfLastTransaction") %></p>
	
	<% } %>
	
	<table width="100%" border="0">
	<tr>
		<td>Fund ID</td>
		<td>Fund Name</td>
		<td>Symbol</td>
		<td>Last Price</td>
		<td>New Price</td>
	</tr>
	<%
	Fund [] fundsList = (Fund[])request.getAttribute("fundsList");
	String [] errorPrices = (String[])request.getAttribute("fundsErrorPrices");
	double [] fundsPrices = new double[0];
	out.println(fundsList.length);
	if (fundsList != null){
	    //fundsList = (Fund[])request.getAttribute("fundsList");
	    fundsPrices = (double[])request.getAttribute("fundsPrices");
	
		for (int i = 0; i < fundsList.length; i++) {
			Fund tempFund = fundsList[i];
			//double tempPrice = fundsPrices[i];
			%><tr>
			<td><%= i+1 %></td>
			<td><%= tempFund.getName() %></td>
			<td><%= tempFund.getSymbol() %></td>
			<td><%= fundsPrices[i]%></td>
			<td><input type="text" name="txtNewFundPrice<%= tempFund.getFundID() %>" size="10" value="<% if (errorPrices!=null) { out.println(errorPrices[i]); } %>" /></td>
		</tr><%
		}
	}
%>
	</table>
	
	<input type="submit" value="Submit" name="Submit" />
	</form>
	
</body>
</html>